package fr.afcepf.ai89.esharing.data;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import fr.afcepf.ai89.esharing.entity.FrNoTel;
import fr.afcepf.ai89.esharing.entity.Proprietaire;

@Stateless
public class DAOFrNoTel implements IDAOFrNoTel {
	
	@PersistenceContext(unitName = "ESharingPhase22")
	EntityManager em;
	
	@Override
	public FrNoTel getFrNoTel(int idFrNoTel) {
		
		Query hql = em.createQuery("SELECT n FROM FrNoTel n WHERE n.noTelFr = :param" );
				
		hql.setParameter("param", (long)idFrNoTel);
		FrNoTel noTel = (FrNoTel)hql.getSingleResult();
		return noTel;
		
	}

	@Override
	public List<FrNoTel> getFrNosTels() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int addNoTel(FrNoTel frNoTel) {
		
		em.persist(frNoTel);
		return (int) frNoTel.getNoTelFr();
		
	}

	@Override
	public int majNoTel(FrNoTel frNoTel) {
		// TODO Auto-generated method stub
		return 0;
	}

}
